Skip to content

Fix nextjs quickstart middleware pattern to use asgardeoMiddleware#456

Open
udanfernando2006 wants to merge 2 commits intoasgardeo:mainfrom
udanfernando2006:udanfernando2006/docs/fix-nextjs-quickstart-middleware
Open

Fix nextjs quickstart middleware pattern to use asgardeoMiddleware#456
udanfernando2006 wants to merge 2 commits intoasgardeo:mainfrom
udanfernando2006:udanfernando2006/docs/fix-nextjs-quickstart-middleware

Conversation

@udanfernando2006
Copy link
Copy Markdown

@udanfernando2006 udanfernando2006 commented Apr 15, 2026

Purpose

The QUICKSTART.md was using outdated API patterns (new AsgardeoNext() with .middleware() method) that don't match the current SDK implementation. This could confuse developers following the guide, as the code wouldn't work.

Updated to use the correct asgardeoMiddleware function exported from @asgardeo/nextjs/server, which aligns with the official Asgardeo documentation.

Related Issues

  • Addresses inconsistency between documented and actual SDK API.

Related PRs

  • N/A

Checklist

  • Followed the CONTRIBUTING guidelines.
  • Documentation provided.
  • No unit tests needed (documentation-only).

Security checks

  • N/A (documentation-only change).

Summary by CodeRabbit

  • Documentation
    • Simplified Quickstart middleware instructions for Next.js, showing a streamlined authentication middleware export.
    • Updated embedded login examples to use the new middleware pattern and demonstrate configuring a sign-in redirect.
    • Clarified Next.js 16 middleware/proxy filename differences and recommended compatibility approach.

@pavinduLakshan
Copy link
Copy Markdown
Contributor

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 18, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 18, 2026

📝 Walkthrough

Walkthrough

Updated Next.js Quickstart docs to replace manual AsgardeoNext instantiation and middleware(request) wrapper with export default asgardeoMiddleware() usage; added a note about Next.js 16 renaming middleware.tsproxy.ts. (Documentation-only change.)

Changes

Cohort / File(s) Summary
Quickstart Documentation
packages/nextjs/QUICKSTART.md
Replaced examples that manually instantiate and initialize AsgardeoNext and use export async function middleware(request: NextRequest) { ... } with the export default asgardeoMiddleware() pattern (including export default asgardeoMiddleware(undefined, { signInUrl: '/signin' })). Added mention of Next.js 16 middleware.tsproxy.ts rename and noted SDK targets middleware.ts pattern.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I hopped through docs with nimble feet,
Swapped boilerplate for something neat,
One export now sings the tune,
Quickstart ready—set by noon! 🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: updating the Next.js quickstart middleware pattern to use the correct asgardeoMiddleware function instead of outdated API patterns.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The PR description comprehensively addresses the purpose, issues, related items, and security considerations for this documentation-only change.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/nextjs/QUICKSTART.md`:
- Around line 214-219: The documentation example passes the configuration object
as the first argument to asgardeoMiddleware, but the function signature expects
an optional handler as the first parameter and options as the second; update the
example so the options object (containing signInUrl) is provided as the second
argument to asgardeoMiddleware, e.g. call asgardeoMiddleware with undefined for
the handler when you only need options, or pass your handler function first and
the options object second (references: asgardeoMiddleware, handler, options,
signInUrl).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1d9805a2-85aa-4976-b4b3-d7219e04cf86

📥 Commits

Reviewing files that changed from the base of the PR and between ae01ffe and eb0c64e.

📒 Files selected for processing (1)
  • packages/nextjs/QUICKSTART.md

Comment thread packages/nextjs/QUICKSTART.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants